package com.demo.common.redis.stream;

import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;

/**
 * <p>
 *
 * </p>
 *
 * @author molong
 * @date 2022/6/22
 */
public class BaseStreamConfig {

    /**
     * 定义消息处理容器
     * @param factory 工厂类
     * @return 获取结果
     */
    @Bean
    public StreamMessageListenerContainer streamMessageContainer(RedisConnectionFactory factory){
        //容器的启动和监听的注册都放到ApplicationStartedEvent 事件处理程序中
        return StreamMessageListenerContainer.create(factory);
    }

}
